Skip to content

TW-Test#3

Open
timmyd4 wants to merge 5 commits intogrc-cohort-21:mainfrom
timmyd4:main
Open

TW-Test#3
timmyd4 wants to merge 5 commits intogrc-cohort-21:mainfrom
timmyd4:main

Conversation

@timmyd4
Copy link
Copy Markdown

@timmyd4 timmyd4 commented Jan 10, 2025

No description provided.

Copy link
Copy Markdown

@auberonedu auberonedu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job! See comments below for a few things to consider. Make sure to always be running your code and checking that the output matches what's expected.

Comment thread src/ListPractice.java

public static void main(String[] args) {
// Create an empty ArrayList of Strings and assign it to a variable of type List
ArrayList<String> EmptyList = new ArrayList<>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to use interface types where appropriate (List)

Also, in general we have our variables and methods in Java be in camelCase, where the first letter is lowercase. We have classes and interfaces be capitalized.

Comment thread src/MapPractice.java
public static void main(String[] args) {
// Create a HashMap with String keys and Integer values and
// assign it to a variable of type Map
HashMap<String, Integer> workingMap = new HashMap<>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to use interface types where appropriate (Map)

Comment thread src/MapPractice.java
Comment on lines +34 to +49
for(int i = 0; i < workingMap.size(); i++)
{
System.out.println(workingMap.keySet());
}
// Iterate over the values of the map, printing each value


for(int i = 0; i < workingMap.size(); i++)
{
System.out.println(workingMap.values());
}
// Iterate over the entries in the map, printing each key and value

for(int i = 0; i < workingMap.size(); i++)
{
System.out.println(workingMap);
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These don't quite work. This goes and repeatedly prints out all of the keys, then all of the values, then the entire set. We want them one at a time. Consider using a for-each loop for these. Make sure to run your code to check whether it does what you're wanting.

Comment thread src/Person.java
Comment on lines +8 to +10
String name;
// Declare a private int instance variable for the age of the person

int age;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to public and private access modifiers to make these have the access specified by the comments.

Comment thread src/SetPractice.java
public class SetPractice {
public static void main(String[] args) {
// Create a HashSet of Strings and assign it to a variable of type Set
HashSet<String> hashSetValue = new HashSet<String>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to use interface types where appropriate (Set)

Comment thread src/StringPractice.java
public static void main(String[] args) {
// Create a string with at least 5 characters and assign it to a variable
String letters = "Hello World";
String AssignString = letters;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto here and elsewhere on camelCase

Comment thread src/StringPractice.java
}

// Create an ArrayList of Strings and assign it to a variable
ArrayList<String> ValueList = new ArrayList<String>();
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to use interface types where appropriate (List)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants